package com.abe.libphoto;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;


public class TakePhotoActivity extends Activity {
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_take_photo);
        findViewById(R.id.item_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AbeMultiMedia.with(TakePhotoActivity.this)
                        .setType(AbeMultiMedia.TYPE_TAKE_PHOTO)
                        .setCallBack(new AbeMultiMedia.OnAbeMultiMediaCallBack() {
                            @Override
                            public void onPhoto(int type, String imagePath, Bitmap bitmap) {
                                System.out.println("type:" + type + "\nimagePath:" + imagePath);
                            }
                        }).start();
            }
        });

        findViewById(R.id.item_button_album).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                AbeMultiMedia.with(TakePhotoActivity.this)
                        .setType(AbeMultiMedia.TYPE_ALBUM_SELECT)
                        .setCallBack(new AbeMultiMedia.OnAbeMultiMediaCallBack() {
                            @Override
                            public void onPhoto(int type, String imagePath, Bitmap bitmap) {
                                System.out.println("type:" + type + "\nimagePath:" + imagePath);
                            }
                        }).start();
            }
        });
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        AbeMultiMedia.with(this).onActivityResult(requestCode, resultCode, data);
        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public void onDestroy() {
        AbeMultiMedia.with(this).destroy();
        super.onDestroy();
    }
}
